package com.moter.one.wyydemo1.controller;

import com.moter.one.wyydemo1.backstage.vo.DataVo;
import com.moter.one.wyydemo1.entity.SongInfo;
import com.moter.one.wyydemo1.service.SongInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Random;

@Controller
public class RandomMusic {
    @Autowired
    SongInfoService songInfoService;

    @ResponseBody
    @RequestMapping("randomMusic")
    public DataVo<SongInfo> getRandomMusic(){
        Random random = new Random();
        DataVo dataVo = null;

        int num = random.nextInt(60)+1;
        SongInfo songInfo = songInfoService.selectById(num);
//        System.out.println(songInfo);
        dataVo = new DataVo<>(0, "获取成功",songInfo, 123);

        return dataVo;
    }
}
